#include<iostream>
#include<random>
#include<ctime>
#include<cstring>
#define ull unsigned long long
using namespace std;
mt19937_64 rng(time(0));
const int N=1e6+5;
int tot=1,nxt[N<<1],head[N],to[N<<1];
int vis[N],n,m,Q;
ull w[N];
inline void add(int u,int v){nxt[++tot]=head[u],to[tot]=v,head[u]=tot;}
ull dfs(int x,int fa){
	ull sum=0;
	vis[x]=1;
	for(int i=head[x];i;i=nxt[i])
		if(!vis[to[i]]) w[i>>1]=dfs(to[i],x),sum^=w[i>>1];
		else if(to[i]!=fa&&!w[i>>1]) w[i>>1]=rng()+1,sum^=w[i>>1];
		else sum^=w[i>>1];
	return sum;
}
ull p[70];
inline bool ins(ull val){
	for(int i=63;~i;--i)
		if(val>>i&1){
			if(p[i]) val^=p[i];
			else return p[i]=val,0;
		}
	return 1;
}
signed main(){
	freopen("graph.in","r",stdin);
	freopen("graph.out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	for(int i=1,x,y;i<=m;++i) cin>>x>>y,add(x,y),add(y,x);
	dfs(1,0),cin>>Q;
	while(Q--){
		int fl=0,c;
		cin>>c,memset(p,0,sizeof p);
		for(int i=1,x;i<=c;++i) cin>>x,fl|=ins(w[x]);
		puts(fl?"NO":"YES");
	}
}